import {
    getInspectionFormReport, //详情
} from "@/api/request.js";
export default {
    props: [
        "dialogVisible",
        "dialogTitle",
        "statusNum",
        "currentRow",
    ],
    // 
    data() {
        return {
            visible: "",
            loading: false,
            title: null,
            tableTitle: "",//大标题
            tableTitle1: "原材料报验单",//小标题
            newRow: null,
            formData: {

            },
            // 顶部信息
            informationList: [
                {
                    title: "施工单位：",
                    content: ""
                },
                {
                    title: "合同号：",
                    content: ""
                },
                {
                    title: "监理单位：",
                    content: ""
                },
                {
                    title: "编号：",
                    content: ""
                },
            ],
            // 表格1
            materialTableList: [
                {
                    title: "材料名称", name1: '', name2: '', name3: '',
                },
                {
                    title: "材料来源、产地", name1: '', name2: '', name3: '',
                },
                {
                    title: "材料规格", name1: '', name2: '', name3: '',
                },
                {
                    title: "用途(工程或部位)", name1: '', name2: '', name3: '',
                },
                {
                    title: "本批次材料数量", name1: '', name2: '', name3: '',
                },
            ],
            // 表格2
            tableTwoList: [
                { title: "取样地点、日期", con1: '', con2: '', con3: '', con4: '', con5: '', con6: '' },
                { title: "试样数量", con1: '', con2: '', con3: '', con4: '', con5: '', con6: '' },
                { title: "试验日期", con1: '', con2: '', con3: '', con4: '', con5: '', con6: '' },
                { title: "试验结果", con1: '', con2: '', con3: '', con4: '', con5: '', con6: '' },
                { title: "试验报告编号", con1: '', con2: '', con3: '', con4: '', con5: '', con6: '' },
            ],
        };
    },
    components: {
    },
    watch: {
        dialogVisible: {
            handler(newVal) {
                if (newVal) {
                    this.visible = newVal;
                }
            },
            immediate: true,
        },
        dialogTitle: {
            handler(newVal) {
                if (newVal) {
                    this.title = newVal;
                }
            },
            immediate: true,
        },
        statusNum: {
            handler(newVal) {
                if (newVal) {
                    // console.log(newVal);
                }
            },
            immediate: true,
        },

        currentRow: {
            handler(newVal) {
                if (newVal) {
                    // 
                    this.newRow = newVal;
                    console.log("行信息", this.newRow);
                    if (this.statusNum != 1) {
                        this.getDetail({
                            fId: this.newRow.fId
                        })
                    } // currentRow
                }
            },
            immediate: true,
        },

    },
    created() {
        window.addEventListener("resize", this.getHeight);
        // this.getHeight();
    }, //获取页面高度自适应：

    destroyed() {
        window.removeEventListener("resize", this.getHeight);
        // this.getHeight();
    },
    mounted() {
        this.userInfo = JSON.parse(sessionStorage.getItem("GxBack-userInfo"));
    },
    methods: {
        // getHeight() {
        //     var h = document.documentElement.clientHeight; //获取页面可见高度
        //     this.dialogHeight = h * 1 + "px";
        // },

        closeDialog() {
            this.$emit("close");
        },


        // 详情
        getDetail(obj) {
            this.loading = true;
            getInspectionFormReport(obj).then((res) => {
                if (res.errcode == 0) {
                    this.loading = false;
                    this.formData = res.data;
                    this.tableTitle = this.formData.fCompanyfullname;//大标题
                    this.informationList[0].content = this.formData.fCompanygsname;//施工单位
                    this.informationList[1].content = this.formData.fEncode;//合同号
                    this.informationList[2].content = this.formData.fJlgsname;//监理单位
                    this.informationList[3].content = this.formData.fInspectionnostr;//编号
                    // 表格1
                    this.materialTableList[0].name1 = this.formData.fMaterialname;//材料名称
                    this.materialTableList[1].name1 = this.formData.fManufacturername;//材料来源、产地
                    this.materialTableList[2].name1 = this.formData.fSpecification;//材料规格
                    this.materialTableList[3].name1 = this.formData.fIntendeduse;//用途(工程或部位)
                    this.materialTableList[4].name1 = this.formData.fEntrynum;//本批次材料数量

                    //表格2
                    this.tableTwoList[0].con1 = this.formData.fAddress;//取样地点
                    this.tableTwoList[1].con1 = this.formData.fDeputynum;//试样数量
                    this.tableTwoList[2].con1 = this.formData.fReportdates;//试验日期--结束
                    this.tableTwoList[3].con1 = this.formData.fReportresult;//试验结果
                    this.tableTwoList[4].con1 = this.formData.fSamplereportnostr;//试验报告编号

                    this.formData.jlSampleList.map((item, index) => {
                        var num = 'con' + (4 + index);
                        this.tableTwoList[0][num] = item.fAddress;//取样地点
                        this.tableTwoList[1][num] = item.fDeputynum;//试样数量
                        this.tableTwoList[2][num] = item.fReportdates;//试验日期--结束
                        this.tableTwoList[3][num] = item.fReportresult;//试验结果
                        this.tableTwoList[4][num] = item.fSamplereportnostr;//试验报告编号
                    })
                } else {
                    this.loading = false;
                    this.$message.error({
                        content: "详情数据获取失败" + res.msg,
                        duration: 1000
                    });
                }
            });
        },


    },
};